// 引入公共css
require("../../assets/css/normalize.css");
require("../../assets/css/reset.css");
require("../../assets/css/basic.css");
require("../../assets/css/property.css");
require("../../assets/fonts/word-img/iconfont.css");
let dom = require("../../assets/js/util.js");
// axios
const axios = require("../../assets/js/axios");
// 引入自己的
require("./myBadge.less");

// 引入图片

// 普通js
window.addEventListener("DOMContentLoaded", function () {
	// 引入图片
	let img1 = require("../../assets/images/mybadge01.jpg");
	let img2 = require("../../assets/images/mybadge02.jpg");
	let img3 = require("../../assets/images/mybadge03.jpg");
	let img4 = require("../../assets/images/mybadge04.jpg");
	let img5 = require("../../assets/images/mybadge05.jpg");
	let img6 = require("../../assets/images/mybadge06.jpg");
	let img7 = require("../../assets/images/mybadge07.jpg");
	let img8 = require("../../assets/images/mybadge08.jpg");
	let img9 = require("../../assets/images/mybadge09.jpg");
	console.log(img1);
	// 返回
	dom.$("header .icon-left3").addEventListener("click", function () {
		location.href = "mine.html";
	});

	// 获取徽章，发送请求
	axios.get("/api/exercise/badge").then((res) => {
		console.log(res);
		let data = res.data.data;
		console.log(data);
		// 渲染
		data.forEach((v) => {
			dom.$(
				"main"
			).innerHTML += `  <a class="dpflex" href="badge1-detail.html?id=${v.id}">
		<img src="${img1}" alt="error：Img loading">
		<span>${v.name}</span>
	</a>`;
		});
	});

	// 发送请求--rank
	axios.get("/api/user/info").then((res) => {
		// 成功
		// 渲染排名--在res.data.data.ranking
		dom.$("#rankNumber").textContent = res.data.data.ranking;
	});
});
